package com.example.jpademo.repository;

import com.example.jpademo.model.Product;
import jakarta.persistence.EntityManager;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;

import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.Optional;

@RunWith(SpringRunner.class)
@SpringBootTest
public class ProdcutRepositoryTestor {


    @Autowired
    private ProductRepository productRepository;




    @Test
    public  void testSelectAll(){

        Iterable<Product> list = productRepository.findAll();

        System.out.println(list);

    }


    @Test
    public void testSave(){

          Product product = new Product();
         // product.setProduct_id(1L);
          product.setProduct_name("test007");


           productRepository.save(product);




    }
}
